angular.module("app.stat").register.controller("ListNcCtrl", ["$scope", "$http", "$state", "$modal", "$modalService", function($scope, $http, $state, $modal, $modalService){
  $scope.stores = [];
  $scope.loadTip = '请输入查询号码...........';
  $scope.data = {
    entity: {}
  };
  $scope.filter = {
    mobile: ''
  };
  $scope.gets = function(){
    $scope.loadTip = '正在获取数据...........';
    $scope.stores = [];
    $http.post('/stat/nc/gets/', {
      mobile: $scope.filter.mobile
    }, {
      transformRequest: function(data){
        return $.param(data);
      }
    }).success(function(ret){
      if(ret.status){
        $scope.stores = ret.data;
        $scope.stores.length == 0 ? $scope.loadTip = '请输入查询号码...........' : '';
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
  $scope.refresh = function(){
    $scope.stores = [];
    $scope.gets();
  };
  $scope.add = function(){
    var $modalInstance = $modal.open({
      templateUrl: "/stat/nc/add/",
      controller: "AddNcCtrl",
      backdrop: true,
      resolve: {
        data: function(){
          return $scope.data;
        }
      }
    });
    $modalInstance.result.then(function(status){
      if(status == 'success'){
      }
    }, function(status){
      if(status == 'success'){
      }
    });
  };
  $scope.dels = function(){
    var $modalInstance = $modal.open({
      templateUrl: "/stat/nc/dels/",
      controller: "DelsNcCtrl",
      backdrop: true,
      resolve: {
        data: function(){
          return $scope.data;
        }
      }
    });
    $modalInstance.result.then(function(status){
      if(status == 'success'){
      }
    }, function(status){
      if(status == 'success'){
      }
    });
  };
  $scope.bulkUpdate = function(){
    var $modalInstance = $modal.open({
      templateUrl: "/stat/nc/bulkUpdate/",
      controller: "bulkUpdateCtrl",
      backdrop: true,
      resolve: {
        data: function(){
          return $scope.data;
        }
      }
    });
    $modalInstance.result.then(function(status){
      if(status == 'success'){
      }
    }, function(status){
      if(status == 'success'){
      }
    });
  };
  $scope.remove = function(mobile){
    $modalService.myConfirm("删除以后内容不能恢复，您是否确认删除？", function(){
      $http.post('/stat/nc/remove/', {
        mobile: mobile
      }, {
        transformRequest: function(data){
          return $.param(data);
        }
      }).success(function(ret){
        if(ret.status){
          $modalService.myAlert('删除成功!');
          $scope.refresh();
          $scope.filter.mobile = '';
        }else{
          $modalService.myAlert(ret.data);
        }
      }).error(function(){
        $modalService.myAlert('系统错误，请求资源失败！');
      });
    }, function(){
    });
  };
  $scope.search = function(){
    $scope.refresh();
  }
}]);
angular.module("app.stat").register.controller("bulkUpdateCtrl", ["$scope", "$http", "$modalInstance", "$modalService", "data", function($scope, $http, $modalInstance, $modalService, data){
  $scope.entity = data.entity;
  $scope.cancel = function(){
    $modalInstance.dismiss("cancel");
  };
  $scope.submit = function(){
    $http.post('/stat/nc/bulkUpdate', $scope.entity, {
      transformRequest: function(data){
        return $.param(data);
      }
    }).success(function(ret){
      if(ret.status){
        $modalService.myAlert(ret.data);
        $modalInstance.close('success');
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
}]);
angular.module("app.stat").register.controller("AddNcCtrl", ["$scope", "$http", "$modalInstance", "$modalService", "data", function($scope, $http, $modalInstance, $modalService, data){
  $scope.entity = data.entity;
  $scope.cancel = function(){
    $modalInstance.dismiss("cancel");
  };
  $scope.submit = function(){
    $http.post('/stat/nc/add', $scope.entity, {
      transformRequest: function(data){
        return $.param(data);
      }
    }).success(function(ret){
      if(ret.status){
        $modalService.myAlert(ret.data);
        $modalInstance.close('success');
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
}]);
angular.module("app.stat").register.controller("DelsNcCtrl", ["$scope", "$http", "$modalInstance", "$modalService", "data", function($scope, $http, $modalInstance, $modalService, data){
  $scope.entity = data.entity;
  $scope.cancel = function(){
    $modalInstance.dismiss("cancel");
  };
  $scope.submit = function(){
    $http.post('/stat/nc/dels', $scope.entity, {
      transformRequest: function(data){
        return $.param(data);
      }
    }).success(function(ret){
      if(ret.status){
        $modalService.myAlert(ret.data);
        $modalInstance.close('success');
      }else{
        $modalService.myAlert(ret.data);
      }
    }).error(function(){
      $modalService.myAlert('系统错误，请求资源失败！');
    });
  };
}]);